const mongoose = require('mongoose')
const Scheam = mongoose.Schema;
const ProfileScheam = new Scheam({
    title: {
        type: String,
        trim: true
    },
    content: {
        type: String,
        // set 修饰符  创建数据库时 的操作
        // set: function(url) {
        //     if (!url) return url;
        //     if (0 !== url.indexOf('http://') && 0 !== url.indexOf('https://')) {
        //         url = "http://+url"
        //         return url
        //     }
        // }
        default: "我是内容"
    },

    class: {
        type: String,
        default: "我是class"
    },
    visits: {
        type: Number,
        default: 100
    },
    /*分类 id*/
    author_id: {
        type: Scheam.Types.ObjectId,
        ref: "User" //author_id和 用户表建立关系。   model
    },
    /*用户的id*/
    cid: {

        type: Scheam.Types.ObjectId,
        ref: "ArticleCate" //cid和 文章分类建立关系。哪个表是外键就放在哪个表   model    
    },


    data: {
        type: Date,
        default: Date.now
    },

})
module.exports = Profile = mongoose.model("Profile", ProfileScheam)